<template>
  <div class="app-container">
    <el-form :inline="true" :model="queryParam" class="demo-form-inline">
      <el-form-item>
        <el-input
          v-model="queryParam.name"
          placeholder="请输入权限名称"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          @click="searchQuery"
        >查询权限</el-button>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-refresh-right"
          @click="reset"
        >重置</el-button>
      </el-form-item>
      <!-- <el-form-item>
        <el-button type="primary" @click="handleAdd" icon="el-icon-plus"
          >新增权限</el-button
        >
      </el-form-item>
      <el-form-item>
        <el-upload
          :action="url.importExcelUrl"
          :limit="1"
          :show-file-list="false"
          :on-success="handleImportExcel"
          ref="upload"
          accept=".xls,.xlsx"
        >
          <el-button type="primary" icon="el-icon-download">导入权限</el-button>
        </el-upload>
      </el-form-item> -->
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-upload2"
          @click="handleExportExcel"
        >导出权限</el-button>
      </el-form-item>
      <el-form-item v-if="selectedIds.length > 0">
        <el-button
          type="danger"
          icon="el-icon-delete"
          @click="handleDeleteBatch()"
        >批量删除</el-button>
      </el-form-item>
    </el-form>
    <el-table
      ref="table"
      v-loading="loading"
      :data="tableData"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
      @selection-change="handleSelectionChange"
      @select="handleSelect"
      @select-all="handleSelectAll"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column align="center" label="权限编号" width="200">
        <template slot-scope="scope">
          {{ scope.row.id }}
        </template>
      </el-table-column>
      <el-table-column label="权限名称" width="200" align="center">
        <template slot-scope="scope">
          {{ scope.row.name }}
        </template>
      </el-table-column>
      <el-table-column label="权限路径" width="250" align="center">
        <template slot-scope="scope">
          {{ scope.row.path }}
        </template>
      </el-table-column>
      <el-table-column label="组件路径" width="350" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.component }}</span>
        </template>
      </el-table-column>
      <el-table-column label="图标" width="200" align="center">
        <template slot-scope="scope">
          {{ scope.row.icon }}
        </template>
      </el-table-column>
      <el-table-column label="创建日期" width="250" align="center">
        <template slot-scope="scope">
          {{ scope.row.gmtCreate }}
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="280" align="center">
        <template slot-scope="scope">
          <el-popconfirm
            confirm-button-text="确认"
            cancel-button-text="取消"
            icon="el-icon-info"
            icon-color="red"
            title="确定删除吗？"
            @onConfirm="fakeDelete(scope.row.id)"
          >
            <el-button slot="reference" type="danger" round size="small">
              删除
            </el-button>
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>
    <div class="block" style="text-align: right">
      <el-pagination
        :current-page="currentPage"
        :page-size="10"
        layout="total, prev, pager, next, jumper"
        :total="pageTotal"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>

<script>
import { RCListMixin } from '@/mixins/RCListMixin'
export default {
  // components: { UserModel },
  mixins: [RCListMixin],
  data() {
    return {
      url: {
        list: '/system/sys-permission/list',
        delete: '/system/sys-permission/deleteById',
        deleteBatch: '/system/sys-permission/deleteBatch',
        importExcelUrl: `${process.env.VUE_APP_BASE_API}/system/sys-permission/importExcel`,
        exportExcelUrl: `/system/sys-permission/exportExcel`
      },
      excelName: '权限列表'
    }
  },
  created() {},
  methods: {
    onSubmit() {
      console.log('submit!')
    },
    fakeDelete() {
      this.$message({
        type: 'warning',
        message: '请不要乱删哦,有需要请联系开发人员'
      })
    }
  }
}
</script>
